package edu.gatech.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class MenuBar {
	private static JFrame currentFrame;
	
	public MenuBar(JFrame frame){
		currentFrame = frame;
		JMenuBar menuBar = new JMenuBar();
        frame.setJMenuBar(menuBar);
        
        JMenu mnFile = new JMenu("File");
        menuBar.add(mnFile);
        
        JMenuItem mntmLogout = new JMenuItem("Logout");
        mntmLogout.addActionListener(new ActionListener() {
        	@Override
        	public void actionPerformed(ActionEvent arg0) {
        			currentFrame.dispose();
        	}
        });
        mnFile.add(mntmLogout);
        
        JMenuItem mntmExit = new JMenuItem("Exit");
        mntmExit.addActionListener(new ActionListener() {
        	@Override
        	public void actionPerformed(ActionEvent arg0) {
        		currentFrame.dispose();
        	}
        });
        mnFile.add(mntmExit);
        
        JMenu mnHelp = new JMenu("Help");
        mnHelp.addMouseListener(new MouseAdapter() {
        	@Override
        	public void mouseClicked(MouseEvent arg0) {
        		JOptionPane.showMessageDialog(currentFrame, 
						"Please contact a system administrator" + "\n" +
						"for this Doctor Office System for help.",
						"Help", 1);
        	}
        });
        menuBar.add(mnHelp);
        
        JMenu mnAbout = new JMenu("About");
        mnAbout.addMouseListener(new MouseAdapter() {
        	@Override
        	public void mouseClicked(MouseEvent arg0) {
        		JOptionPane.showMessageDialog(currentFrame, 
						"Doctor Office System." + "\n" +
						"Created by \"The 512's\" for CS2340.",
						"About", 1);
        	}
        });
        menuBar.add(mnAbout);
       
	}
}
